<!--
描述：留言应用-回复管理-添加
开发人：yyp
开发日期：2019/10/26
-->
<template lang="pug">
  kalix-dialog.user-add(bizKey="messagereply" ref="kalixBizDialog" v-bind:submitBefore="submitBefore"
  v-bind:submitAfter="submitAfter" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
    div.el-form(slot="dialogFormSlot")
      input(v-model="formModel.id" type="hidden")
      input(v-model="formModel.messageId" type="hidden")
      <!--el-form-item(label="所属帖子内容" prop="messageId" label-width="120px" v-bind:rules="rules.parentContent")-->
        <!--el-tinymce(v-model="formModel.parentContent")-->
      el-form-item(label="回复内容" prop="replyMessage" label-width="120px" v-bind:rules="rules.replyMessage")
        tinymce(v-model="formModel.replyMessage")
</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {MessageReplyURL} from '../../config.toml'

  export default {
    name: 'messagereplyEdit',
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        rules: {
          replyEnclosure: [{required: true, message: '请输入回复内容', trigger: 'blur'}]
        },
        targetURL: MessageReplyURL,
        labelWidth: '110px',
        tempParent: undefined,
        tempChildren: undefined
      }
    },
    components: {
    },
    methods: {
      submitBefore(baseDialog, callBack) {
        if (baseDialog.formModel.parent) {
          this.tempParent = baseDialog.formModel.parent
          baseDialog.formModel.parent = undefined
        }
        if (baseDialog.formModel.children) {
          this.tempChildren = baseDialog.formModel.children
          baseDialog.formModel.children = undefined
        }
        callBack()
      },
      submitAfter(baseDialog, callBack) {
        if (this.tempParent) {
          baseDialog.formModel.parent = this.tempParent
        }
        if (this.tempChildren) {
          baseDialog.formModel.children = this.tempChildren
        }
        // callBack()
      }
    }
  }
</script>

<style scoped>

</style>
